package thinkingJava.chapter15;

import java.lang.reflect.Array;
import java.util.Arrays;

public class ArrayMaker<T> {
	private Class<T> kind;
	public ArrayMaker(Class<T> k) {
		this.kind = k;
	}
	@SuppressWarnings("unchecked")
	T[] create(int size) {
		return (T[])Array.newInstance(kind, size);
	}
	public static void main(String[] args) {
		ArrayMaker<String> ams = new ArrayMaker<String>(String.class);
		String[] strArr = ams.create(5);
		System.out.println(strArr.length);
		System.out.println(Arrays.toString(strArr));
	}

}
